package cn.yunhe.controller;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ControllerAdvice
public class ExceptionController {
    @ExceptionHandler(value = UnauthorizedException.class)//处理访问方法时权限不足问题
    public void defaultErrorHandler(HttpServletResponse response) throws IOException {
        response.sendRedirect("/error.html");
    }

    @ExceptionHandler(value = AuthorizationException.class)//处理访问方法时权限不足问题
    public void toError(HttpServletResponse response) throws IOException {
        response.sendRedirect("/error.html");
    }
}